package com.zhihuishu.micro.course.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.abel533.entity.Example;
import com.github.abel533.entity.Example.Criteria;
import com.github.abel533.mapper.Mapper;
import com.zhihuishu.micro.course.dao.CourseBuildMapper;
import com.zhihuishu.micro.course.model.CourseBuild;
import com.zhihuishu.micro.course.service.CourseBuildService;
@Service("courseBuildService")
public class CourseBuildServiceImpl extends BaseServiceImpl<CourseBuild> implements CourseBuildService {

    @Resource
    private CourseBuildMapper courseBuildMapper;

    @Override
    public Mapper<CourseBuild> getMapper() {
        // TODO Auto-generated method stub
        return courseBuildMapper;
    }

    @Override
    public void updateCourseStepStat(long courseId, int step, int stepStatus) {
        Example example=new Example(CourseBuild.class);
        Criteria createCriteria = example.createCriteria();
        createCriteria.andEqualTo("courseId", courseId);
        CourseBuild courseBuild=new CourseBuild();
        if (step==1) {
            courseBuild.setFirstStatus(stepStatus);
        }
        if (step==2) {
            courseBuild.setSecondStatus(stepStatus);
        }
        if (step==3) {
            courseBuild.setThirdStatus(stepStatus);
        }
        if (step==4) {
            courseBuild.setForthStatus(stepStatus);
        }
        if (step==5) {
            courseBuild.setFifthStatus(stepStatus);
        }
        if (step==6) {
            courseBuild.setSixthStatus(stepStatus);
        }
        getMapper().updateByExampleSelective(courseBuild, example);
        
    }

    @Override
    public CourseBuild queryCourseBuildStatById(long courseId) {
       CourseBuild courseBuild=new CourseBuild();
       courseBuild.setIsDelete(0);
       courseBuild.setCourseId(courseId);
       return getMapper().selectOne(courseBuild);

    }

}
